package com.onelap.bls.tc2.ble;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;

public class BleServiceConnection implements ServiceConnection {

    private BleCallback bleCallback = null;
    private BleServiceConnectionCallback bleServiceConnectionCallback = null;

    BleServiceConnection(BleCallback bleCallback, BleServiceConnectionCallback bleServiceConnectionCallback) {
        this.bleCallback = bleCallback;
        this.bleServiceConnectionCallback = bleServiceConnectionCallback;
    }

    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        if (bleCallback != null)
            bleCallback.bleServiceConnected(componentName, iBinder);
        if (bleServiceConnectionCallback != null)
            bleServiceConnectionCallback.onBleServiceConnectionCallback(componentName, iBinder);
    }

    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        if (bleCallback != null)
            bleCallback.bleServiceDisConnected(componentName);
    }

    /**
     * 蓝牙服务连接回调
     */
    public interface BleServiceConnectionCallback {
        void onBleServiceConnectionCallback(ComponentName componentName, IBinder iBinder);
    }
}
